;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.7.1 #0 (MSVC)
;--------------------------------------------------------
; NY8A port
;--------------------------------------------------------
	.file	"components\button_ctrl_static\btn_ctrl_static.c"
	list	p=NY8B062E,c=on
	#include "ny8b062e.inc"
	.debuginfo language C89
;--------------------------------------------------------
; external declarations
;--------------------------------------------------------
	extern	_sinf
	extern	_cosf
	extern	_tanf
	extern	_cotf
	extern	_asinf
	extern	_acosf
	extern	_atanf
	extern	_atan2f
	extern	_sinhf
	extern	_coshf
	extern	_tanhf
	extern	_expf
	extern	_logf
	extern	_log10f
	extern	_powf
	extern	_sqrtf
	extern	_fabsf
	extern	_frexpf
	extern	_ldexpf
	extern	_ceilf
	extern	_floorf
	extern	_modff
	extern	_isnan
	extern	_isinf
	extern	_multi_16b
	extern	_read_14bit_rom
	extern	_Adc_Start
	extern	_Adc_SetVref
	extern	_Adc_GetOnce
	extern	_Mcu_Delayus
	extern	_Mcu_Delayms
	extern	_SoftCT_EvIOInt
	extern	_SoftCT_EvTimeout
	extern	_SoftCT_GetEvent
	extern	_SoftCT_Run
	extern	_SoftCT_Stop
	extern	_CapSS_Init
	extern	_CapSS_GetValue
	extern	_TouchKey_Init
	extern	_TouchKey_Scan
	extern	_Btn_Event
	extern	_PORTAbits
	extern	_PORTBbits
	extern	_PCONbits
	extern	_BWUCONbits
	extern	_ABPLCONbits
	extern	_BPHCONbits
	extern	_INTEbits
	extern	_INTFbits
	extern	_ADMDbits
	extern	_ADRbits
	extern	_ADVREFHbits
	extern	_ADCRbits
	extern	_AWUCONbits
	extern	_PACONbits
	extern	_ADJMDbits
	extern	_INTEDGbits
	extern	_ANAENbits
	extern	_RFCbits
	extern	_INTE2bits
	extern	__Adc_mDiscard
	extern	__Polsys_mTicked
	extern	_SoftCT_mCaptureValue
	extern	_TouchKey_mKeyStatus
	extern	_INDF
	extern	_TMR0
	extern	_PCL
	extern	_STATUS
	extern	_FSR
	extern	_PORTA
	extern	_PORTB
	extern	_PCON
	extern	_BWUCON
	extern	_PCHBUF
	extern	_ABPLCON
	extern	_BPHCON
	extern	_INTE
	extern	_INTF
	extern	_ADMD
	extern	_ADR
	extern	_ADD
	extern	_ADVREFH
	extern	_ADCR
	extern	_AWUCON
	extern	_PACON
	extern	_ADJMD
	extern	_INTEDG
	extern	_TMRH
	extern	_ANAEN
	extern	_RFC
	extern	_TM3RH
	extern	_INTE2
	extern	_TMR1
	extern	_T1CR1
	extern	_T1CR2
	extern	_PWM1DUTY
	extern	_PS1CV
	extern	_BZ1CR
	extern	_IRCR
	extern	_TBHP
	extern	_TBHD
	extern	_TMR2
	extern	_T2CR1
	extern	_T2CR2
	extern	_PWM2DUTY
	extern	_PS2CV
	extern	_BZ2CR
	extern	_OSCCR
	extern	_TMR3
	extern	_T3CR1
	extern	_T3CR2
	extern	_PWM3DUTY
	extern	_PS3CV
	extern	_BZ3CR
	extern	_P4CR1
	extern	_PWM4DUTY
	extern	_IOSTA
	extern	_IOSTB
	extern	_APHCON
	extern	_PS0CV
	extern	_BODCON
	extern	_CMPCR
	extern	_PCON1
	extern	_T0MD

	extern PSAVE
	extern SSAVE
	extern WSAVE
	extern STK04
	extern STK03
	extern STK02
	extern STK01
	extern STK00
;--------------------------------------------------------
; global declarations
;--------------------------------------------------------
	extern	_Btn_Loop
	extern	_Btn_Init
	extern	__Btn_mIsDown

;--------------------------------------------------------
; global definitions
;--------------------------------------------------------
;--------------------------------------------------------
; absolute symbol definitions
;--------------------------------------------------------
;--------------------------------------------------------
; compiler-defined variables
;--------------------------------------------------------
;--------------------------------------------------------
; initialized data
;--------------------------------------------------------

.segment "idata"
_Btn_mDxd:
	dw	0x00
	.debuginfo gvariable name=_Btn_mDxd,1byte,array=0,entsize=1,ext=0,enc=unsigned


.segment "idata"
_Btn_mUxd:
	dw	0xff
	.debuginfo gvariable name=_Btn_mUxd,1byte,array=0,entsize=1,ext=0,enc=unsigned


.segment "idata"
_Btn_mClickCount:
	dw	0x00
	.debuginfo gvariable name=_Btn_mClickCount,1byte,array=0,entsize=1,ext=0,enc=unsigned


.segment "idata"
__Btn_mIsDown:
	dw	0x00
	.debuginfo gvariable name=__Btn_mIsDown,1byte,array=0,entsize=1,ext=1,enc=unsigned

;--------------------------------------------------------
; overlayable items in internal ram 
;--------------------------------------------------------
;	udata_ovr
;--------------------------------------------------------
; code
;--------------------------------------------------------
;***
;  pBlock Stats: dbName = C
;***
;functions called:
;   _Btn_Event
;   _Btn_Event
;   _Btn_Event
;   _Btn_Event
;   _Btn_Event
;   _Btn_Event
;   _Btn_Event
;   _Btn_Event
;1 compiler assigned register :
;   r0x1005
;; Starting pCode block
.segment "code"; module=btn_ctrl_static, function=_Btn_Loop
	.debuginfo subprogram _Btn_Loop
_Btn_Loop:
; 0 exit points
	.line	58, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(_Btn_HwIsDown())
	BANKSEL	_TouchKey_mKeyStatus
	MOVR	_TouchKey_mKeyStatus,W
	BTRSC	STATUS,2
	MGOTO	_00128_DS_
	.line	60, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mDxd == _BTN_DOWN_DELAY)  //按下时间达到10ms
	BANKSEL	_Btn_mDxd
	MOVR	_Btn_mDxd,W
	BTRSS	STATUS,2
	MGOTO	_00110_DS_
	.line	63, "components\button_ctrl_static\btn_ctrl_static.c"; 	_Btn_mIsDown = true;
	MOVIA	0x01
	BANKSEL	__Btn_mIsDown
	MOVAR	__Btn_mIsDown
	.line	65, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_Event(BTN_EV_DOWN);
	MCALL	_Btn_Event
	.line	66, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_mUxd = 0;
	BANKSEL	_Btn_mUxd
	CLRR	_Btn_mUxd
;;unsigned compare: left < lit (0xFF=255), size=1
_00110_DS_:
	.line	74, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mDxd<0xFF)Btn_mDxd++;
	MOVIA	0xff
	BANKSEL	_Btn_mDxd
	SUBAR	_Btn_mDxd,W
	BTRSC	STATUS,0
	MGOTO	_00130_DS_
	INCR	_Btn_mDxd,F
	MGOTO	_00130_DS_
_00128_DS_:
	.line	78, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mUxd == _BTN_UP_DELAY)   //松手的时间达到20ms执行一次
	BANKSEL	_Btn_mUxd
	MOVR	_Btn_mUxd,W
	BTRSS	STATUS,2
	MGOTO	_00123_DS_
	.line	81, "components\button_ctrl_static\btn_ctrl_static.c"; 	_Btn_mIsDown = false;
	BANKSEL	__Btn_mIsDown
	CLRR	__Btn_mIsDown
	.line	83, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_Event(BTN_EV_UP);     // 通知松手事件
	MOVIA	0x02
	MCALL	_Btn_Event
;;unsigned compare: left < lit (0x24=36), size=1
	.line	84, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mDxd<36)    // 如果按下的时间在0ms~360ms之间，认为是短按
	MOVIA	0x24
	BANKSEL	_Btn_mDxd
	SUBAR	_Btn_mDxd,W
	BTRSC	STATUS,0
	MGOTO	_00116_DS_
	.line	86, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_mClickCount++;
	BANKSEL	_Btn_mClickCount
	INCR	_Btn_mClickCount,F
	.line	90, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mClickCount == 5)
	MOVR	_Btn_mClickCount,W
	XORIA	0x05
	BTRSS	STATUS,2
	MGOTO	_00116_DS_
	.line	91, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_Event(BTN_EV_CLICK_5);    // 5击事件
	MOVIA	0x07
	MCALL	_Btn_Event
_00116_DS_:
	.line	97, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_mDxd = 0;   // 清零按下计时
	BANKSEL	_Btn_mDxd
	CLRR	_Btn_mDxd
	MGOTO	_00124_DS_
_00123_DS_:
	.line	99, "components\button_ctrl_static\btn_ctrl_static.c"; 	else if(Btn_mUxd == 36) // 松手的时间达到360ms
	BANKSEL	_Btn_mUxd
	MOVR	_Btn_mUxd,W
	XORIA	0x24
	BTRSS	STATUS,2
	MGOTO	_00124_DS_
;;unsigned compare: left < lit (0x5=5), size=1
	.line	101, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mClickCount<5&&Btn_mClickCount>1)    // 2~4
	MOVIA	0x05
	BANKSEL	_Btn_mClickCount
	SUBAR	_Btn_mClickCount,W
	BTRSC	STATUS,0
	MGOTO	_00118_DS_
;;swapping arguments (AOP_TYPEs 1/3)
;;unsigned compare: left >= lit (0x2=2), size=1
	MOVIA	0x02
	SUBAR	_Btn_mClickCount,W
	BTRSS	STATUS,0
	MGOTO	_00118_DS_
	.line	103, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_Event(Btn_mClickCount+(BTN_EV_CLICK - 1));
	MOVIA	0x02
	ADDAR	_Btn_mClickCount,W
;;1	MOVAR	r0x1005
	MCALL	_Btn_Event
_00118_DS_:
	.line	105, "components\button_ctrl_static\btn_ctrl_static.c"; 	Btn_mClickCount = 0;
	BANKSEL	_Btn_mClickCount
	CLRR	_Btn_mClickCount
;;unsigned compare: left < lit (0xFF=255), size=1
_00124_DS_:
	.line	107, "components\button_ctrl_static\btn_ctrl_static.c"; 	if(Btn_mUxd<0xFF)Btn_mUxd++;
	MOVIA	0xff
	BANKSEL	_Btn_mUxd
	SUBAR	_Btn_mUxd,W
	BTRSS	STATUS,0
	INCR	_Btn_mUxd,F
_00130_DS_:
	.line	110, "components\button_ctrl_static\btn_ctrl_static.c"; 	}
	RETURN	

;***
;  pBlock Stats: dbName = C
;***
;has an exit
;functions called:
;   _TouchKey_Init
;   _TouchKey_Init
;; Starting pCode block
.segment "code"; module=btn_ctrl_static, function=_Btn_Init
	.debuginfo subprogram _Btn_Init
_Btn_Init:
; 2 exit points
	.line	44, "components\button_ctrl_static\btn_ctrl_static.c"; 	_Btn_HwInit();
	MOVIA	0x01
	MCALL	_TouchKey_Init
	.line	48, "components\button_ctrl_static\btn_ctrl_static.c"; 	}
	RETURN	
; exit point of _Btn_Init


;	code size estimation:
;	   59+   14 =    73 instructions (  174 byte)

	end
